﻿<DemoContainer>
    <ApexChart TItem="Order"
               Title="Order Net Value"
               Options=options>

        <ApexPointSeries TItem="Order"
                         Items="Orders"
                         Name="Gross Value"
                         SeriesType="SeriesType.Bar"
                         XValue="@(e => e.Country)"
                         YAggregate="@(e => e.Sum(e => e.GrossValue))"
                         OrderByDescending="e=>e.Y"
                         ShowDataLabels />

        <ApexPointSeries TItem="Order"
                         Items="Orders"
                         Name="Net Value"
                         SeriesType="SeriesType.Bar"
                         XValue="@(e => e.Country)"
                         YAggregate="@(e => e.Sum(e => e.NetValue))"
                         OrderByDescending="e=>e.Y"
                         ShowDataLabels />
    </ApexChart>
</DemoContainer>

@code {

    private List<Order> Orders { get; set; } = SampleData.GetOrders();
    private ApexChartOptions<Order> options;

    protected override void OnInitialized()
    {
        options = new ApexChartOptions<Order>
            {
                Chart = new Chart
                {
                    Stacked = true,
                },
                PlotOptions = new PlotOptions
                {
                    Bar = new PlotOptionsBar
                    {
                        DataLabels = new PlotOptionsBarDataLabels
                        {
                            Total = new BarTotalDataLabels
                            {
                                Style = new BarDataLabelsStyle
                                {
                                    FontWeight = "800"
                                }
                            }
                        }
                    }
                },
                Colors = new List<string> { "#5cb85c", "#d9534f" }
            };
    }
}

